package com.dave.gd.service.impl;

import java.sql.Timestamp;
import java.util.Date;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.dave.gd.config.sysmgr.SysmgrConstants;
import com.dave.gd.service.IRoleService;
import com.dave.gd.sysmgr.domain.entity.Role;
import com.dave.gd.sysmgr.domain.mapper.RoleMapper;
import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;

@Service("roleServiceImpl")
public class RoleServiceImpl //extends AbstractGenericService<Role, Integer>
implements IRoleService {
    @Resource
    private RoleMapper roleDao;

    @Override
    public int insert(Role t) {
        Date date =new Date();
        Timestamp ttmp = new Timestamp(date.getTime());
        t.setCreatetime(ttmp);
        t.setUptime(ttmp);
        t.setState(SysmgrConstants.NO_STATE);
        
        return this.roleDao.insert(t);
    }


    @Override
    public int delete(long id) {
        return this.roleDao.deleteById(id);
    }


    @Override
    public int update(Role t) {
        Date date =new Date();
        Timestamp ttmp = new Timestamp(date.getTime());
        t.setUptime(ttmp);
        return this.roleDao.update(t);
    }


    @Override
    public Role get(long id) {
        return this.roleDao.queryById(id);
    }


    @Override
    public Page<Role> queryPage(Integer pageNum, Integer pageSize, Role t) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Role> pr = this.roleDao.queryPage(t);
        return pr;
    }
    
}
